// pages/home/home.js
import tx from "../../utils/qqmap-wx-jssdk"
// import QQMapWX from "../../utils/qqmap-wx-jssdk"
// var QQMapWX = require('xxx/qqmap-wx.js');
var qqmapsdk = new tx({
  key:"2G4BZ-6HKKX-QIB4H-Z3S5Z-OAWCT-GNBAH"
})
import { in_theaters,coming_soon,selectPreview } from "../../utils/home/index.js"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    background: [
      {
        classname:'demo-text-1',
        url:"banner1.jpg"
      },
      {
        classname:'demo-text-2',
        url:"banner2.jpg"
      },
      {
        classname:'demo-text-3',
        url:"banner3.jpg"
      },
    ],
    indicatorDots: true,
    vertical: false,
    autoplay: true,
    interval: 2000,
    duration: 500,
    list:[],
    lists:[],
    arr:[]


  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },
  getLocation(){
    var _this = this;
    wx.getLocation({
      success(res){
        console.log(res);
        qqmapsdk.reverseGeocoder({
          location:`${res.latitude},${res.longitude}`,
          success(val){
            console.log(val);
            _this.setData({
              city:val.result.ad_info.city
            })
          }
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    in_theaters()
    .then(res => {
      console.log(res);
      this.setData({
        list:res.data.data.list
      })
    }),
    coming_soon()
    .then(val => {
      console.log(val);
      this.setData({
        lists:val.data.data.list
      })
    }),
    selectPreview()
    .then(vals => {
      console.log(vals);
      this.setData({
        arr:vals.data.data
      })
    })

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getLocation();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})